package com.chiang.nio;

import java.nio.IntBuffer;

/**
 * @author : 765819328@qq.com
 * @version :
 * @date : Created in 2021/7/19 18:02
 * @description: NIO Buffer
 * @modified By:
 */
public class BasicBuffer {
    public static void main(String[] args) {
        //举例说明Buffer的使用
        //创建一个Buffer
        IntBuffer intBuffer = IntBuffer.allocate(5);

        //向Buffer中存放数据
        intBuffer.put(10);
        intBuffer.put(11);
        intBuffer.put(12);
        intBuffer.put(13);
        intBuffer.put(14);


        //从buffer读取数据
        //将buffer转换，读写切换
        intBuffer.flip();

        while (intBuffer.hasRemaining()) {
            System.out.println(intBuffer.get());
        }


    }
}
